package com.pshcp.tool;

import com.alibaba.fastjson.JSON;
import com.pshcp.manager.messagenotification.MessageNotificationDTO;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * @Description: TODO
 * @Author: xiaoche
 * @Date: 2023/3/22 14:14
 */
public class HospitalTool {

    public static Long buildUser2adr2DoctorId(Map<String, String> params) {
        String doctorId = params.get("doctorId");
        return StringUtils.isBlank(doctorId) ? null : Long.parseLong(doctorId);
    }

    public static Long buildUser2adrpatientId(Map<String, String> params) {
        String patientId = params.get("patientId");
        return StringUtils.isBlank(patientId) ? null : Long.parseLong(patientId);
    }

    public static List<Long> buildUser2ad2patientGroup2addUser2patientIds(Map<String, String> params) {
        String patientIds = params.get("patientIds");
        if (StringUtils.isBlank(patientIds)) {
            return Collections.emptyList();
        }
        String[] patientIdsArr = StringUtils.split(patientIds, ",");
        List<Long> list = new ArrayList<>();
        for (String patientId : patientIdsArr) {
            if (StringUtils.isBlank(patientId)) {
                continue;
            }
            list.add(Long.parseLong(patientId));
        }
        return list;
    }

    public static Long buildUser2ad2patientSync2AuditDoctorPatient2DoctorId(Map<String, String> params) {
        String doctorId = params.get("doctorId");
        return StringUtils.isBlank(doctorId) ? null : Long.parseLong(doctorId);
    }

    public static Long buildUser2ad2patientSync2AuditDoctorPatient2PatientId(Map<String, String> params) {
        String patientId = params.get("patientId");
        return StringUtils.isBlank(patientId) ? null : Long.parseLong(patientId);
    }

    public static MessageNotificationDTO buildUser2ad2patientGroup2addUser2MessageNotificationDTO(Long doctorId,Long patientId) {
        MessageNotificationDTO messageNotificationDTO = new MessageNotificationDTO();
        messageNotificationDTO.setTitle("我的患者");
        messageNotificationDTO.setDescription("有新患者加入您的分组啦！点击查看");
        messageNotificationDTO.setContents(null);
        messageNotificationDTO.setMessageType(6);
        messageNotificationDTO.setUserType(0);
        messageNotificationDTO.setUserId(doctorId);
        messageNotificationDTO.setDataId(patientId);
        return messageNotificationDTO;
    }

}
